package com.gxa.customer.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.commons.R;
import com.gxa.common.pojo.Province;
import com.gxa.customer.mapper.ProvinceMapper;
import com.gxa.customer.service.ProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ProvinceServiceImpl extends ServiceImpl<ProvinceMapper, Province> implements ProvinceService {

    @Autowired
    private ProvinceMapper provinceMapper;

    //查询国家对应的地区
    @Override
    public R selectProvinceByCountryId(Long countryId) {
        R r = new R();
        Map map = new HashMap();
        map.put("country_id", countryId);
        List provinceList = provinceMapper.selectByMap(map);

        if(provinceList == null){
            r.setCode(500);
            r.setMsg("查不到数据！！");
            return r;
        }else {
            r.setCode(200);
            r.setMsg("查询成功！");
            r.setData(provinceList);
            return r;
        }
    }
}
